Load MOFA models

MOFA model + xCell + VIPER 25

plotDataOverview(MOFA_m_x25)

Analyze trained MOFA model

# Calculate the variance explained (R2) per factor in each view 
r2 <- calculateVarianceExplained(MOFA_m_x25)
r2$R2Total
##    CyTOF_exp  CyTOF_prcnt RNA_topgenes  RNA_viper25    RNA_xcell     mutation 
##   0.11657600   0.06723003   0.43927647   0.68715897   0.37877534   0.05456125
# Variance explained by each factor in each view
head(r2$R2PerFactor)
##        CyTOF_exp CyTOF_prcnt RNA_topgenes RNA_viper25   RNA_xcell     mutation
## LF1 0.0118403200 0.015294301   0.09931202  0.14660778 0.090561784 5.395057e-02
## LF2 0.0002113100 0.001318306   0.09359987  0.15741472 0.112534474 8.975259e-05
## LF3 0.0001264806 0.005575375   0.05099167  0.08656500 0.093494019 4.292479e-05
## LF4 0.0883613034 0.026199139   0.04140564  0.02766502 0.005864836 5.203288e-05
## LF5 0.0003591671 0.003908529   0.02327361  0.10864514 0.025851111 8.328968e-05
## LF6 0.0161619776 0.013081427   0.01709465  0.05864921 0.017377530 2.675858e-05
# Plot it
plotVarianceExplained(MOFA_m_x25)

Characterization of individual factors

CyTOF percentages

plotWeightsHeatmap(
  MOFA_m_x25, 
  view = "CyTOF_prcnt", 
  factors = 1:5,
  show_colnames = T, main = 'CyTOF_prcnt'
)

plotTopWeights(
  MOFA_m_x25, 
  view="CyTOF_prcnt", 
  factor=5
)

plotTopWeights(
  MOFA_m_x25, 
  view="CyTOF_prcnt", 
  factor=4
)

plotTopWeights(
  MOFA_m_x25, 
  view="CyTOF_prcnt", 
  factor=2
)

CyTOF expression

plotWeightsHeatmap(
  MOFA_m_x25, 
  view = "CyTOF_exp", 
  factors = 1:5,
  show_colnames = FALSE, main = 'CyTOF_exp'
)

plotTopWeights(
  MOFA_m_x25, 
  view="CyTOF_exp", 
  factor=3
)

plotTopWeights(
  MOFA_m_x25, 
  view="CyTOF_exp", 
  factor=5
)

plotTopWeights(
  MOFA_m_x25, 
  view="CyTOF_exp", 
  factor=1
)

plotTopWeights(
  MOFA_m_x25, 
  view="CyTOF_exp", 
  factor=2
)

RNA Seq Top genes

plotWeightsHeatmap(
  MOFA_m_x25, 
  view = "RNA_topgenes", 
  factors = 1:5,
  show_colnames = FALSE, main = 'RNA_topgenes'
)

plotTopWeights(
  MOFA_m_x25, 
  view="RNA_topgenes", 
  factor=1
)

plotTopWeights(
  MOFA_m_x25, 
  view="RNA_topgenes", 
  factor=1
)

plotTopWeights(
  MOFA_m_x25, 
  view="RNA_topgenes", 
  factor=1
)

plotTopWeights(
  MOFA_m_x25, 
  view="RNA_topgenes", 
  factor=1
)

RNA Seq Deconvolution

plotWeightsHeatmap(
  MOFA_m_x25, 
  view = "RNA_xcell", 
  factors = 1:5,
  show_colnames = T, main = 'RNA_xcell'
)

plotTopWeights(
  MOFA_m_x25, 
  view="RNA_xcell", 
  factor=2
)

plotTopWeights(
  MOFA_m_x25, 
  view="RNA_xcell", 
  factor=1
)

plotTopWeights(
  MOFA_m_x25, 
  view="RNA_xcell", 
  factor=4
)

plotTopWeights(
  MOFA_m_x25, 
  view="RNA_xcell", 
  factor=5
)

WES

plotWeightsHeatmap(
  MOFA_m_x25, 
  view = "mutation", 
  factors = 1:5,
  show_colnames = F, main = 'Mutation Data'
)

plotTopWeights(
  MOFA_m_x25, 
  view="mutation", 
  factor=1
)

plotTopWeights(
  MOFA_m_x25, 
  view="mutation", 
  factor=1
)

plotTopWeights(
  MOFA_m_x25, 
  view="mutation", 
  factor=1
)

plotTopWeights(
  MOFA_m_x25, 
  view="mutation", 
  factor=1
)

Feature set enrichment analysis in the active views

# Load reactome annotations
data("reactomeGS") # binary matrix with feature sets in rows and features in columns

# perform enrichment analysis
gsea <- runEnrichmentAnalysis(
  MOFA_m_x25,
  view = "RNA_topgenes",
  feature.sets = reactomeGS,
  alpha = 0.01
)
## Doing Feature Set Enrichment Analysis with the following options...
## View: RNA_topgenes
## Factors: LF1 LF2 LF3 LF4 LF5 LF6 LF7 LF8 LF9 LF10
## Number of feature sets: 640
## Local statistic: loading
## Transformation: abs.value
## Global statistic: mean.diff
## Statistical test: parametric
plotEnrichmentBars(gsea, alpha=0.01)

interestingFactors <- 1:2

fseaplots <- lapply(interestingFactors, function(factor) {
  plotEnrichment(
    MOFA_m_x25,
    gsea,
    factor = factor,
    alpha = 0.01,
    max.pathways = 10 # The top number of pathways to display
  )
})

cowplot::plot_grid(fseaplots[[1]], fseaplots[[2]],
                   ncol = 1, labels = paste("Factor", interestingFactors))

interestingFactors <- 3:4

fseaplots <- lapply(interestingFactors, function(factor) {
  plotEnrichment(
    MOFA_m_x25,
    gsea,
    factor = factor,
    alpha = 0.01,
    max.pathways = 10 # The top number of pathways to display
  )
})

cowplot::plot_grid(fseaplots[[1]], fseaplots[[2]],
                   ncol = 1, labels = paste("Factor", interestingFactors))

interestingFactors <- 5:6

fseaplots <- lapply(interestingFactors, function(factor) {
  plotEnrichment(
    MOFA_m_x25,
    gsea,
    factor = factor,
    alpha = 0.01,
    max.pathways = 10 # The top number of pathways to display
  )
})

cowplot::plot_grid(fseaplots[[1]], fseaplots[[2]],
                   ncol = 1, labels = paste("Factor", interestingFactors))

plotFactorScatter(
  MOFA_m_x25,
  factors = 1:2,
  color_by = "ImmuneScore"      # color by the IGHV values that are part of the training data
  #shape_by = "trisomy12"  # shape by the trisomy12 values that are part of the training data
)

plotFactorScatters(
  MOFA_m_x25,
  factors = c(1:5),
  color_by = "ImmuneScore"
)
## Registered S3 method overwritten by 'GGally':
##   method from   
##   +.gg   ggplot2

plotFactorScatters(
  MOFA_m_x25,
  factors = c(1:5),
  color_by = "Th_cells"
)

plotFactorScatters(
  MOFA_m_x25,
  factors = c(1:5),
  color_by = "Tc_cells"
)

plotFactorScatters(
  MOFA_m_x25,
  factors = c(1:5),
  color_by = "KRAS"
)

plotFactorScatters(
  MOFA_m_x25,
  factors = c(1:5),
  color_by = "EGFR"
)

MOFA model + xCell + VIPER 4

plotDataOverview(MOFA_m_x4)

Analyze trained MOFA model

# Calculate the variance explained (R2) per factor in each view 
r2 <- calculateVarianceExplained(MOFA_m_x4)
r2$R2Total
##    CyTOF_exp  CyTOF_prcnt RNA_topgenes   RNA_viper4    RNA_xcell     mutation 
##   0.11576769   0.06624335   0.43926083   0.57566158   0.37905682   0.05759554
# Variance explained by each factor in each view
head(r2$R2PerFactor)
##        CyTOF_exp CyTOF_prcnt RNA_topgenes RNA_viper4   RNA_xcell     mutation
## LF1 0.0113030430 0.015172115   0.10020041 0.12228920 0.088427725 5.701099e-02
## LF2 0.0001943663 0.001282022   0.09267818 0.13254738 0.114530255 7.739652e-05
## LF3 0.0001225166 0.005556197   0.05100182 0.07772323 0.094508949 4.457243e-05
## LF4 0.0883818991 0.026203092   0.04135978 0.01985176 0.005879997 5.094061e-05
## LF5 0.0002796930 0.003733890   0.02359641 0.07918044 0.028225011 8.407998e-05
## LF6 0.0159356064 0.012416670   0.01708104 0.03951246 0.017624428 2.669282e-05
# Plot it
plotVarianceExplained(MOFA_m_x4)

Characterization of individual factors

CyTOF percentages

plotWeightsHeatmap(
  MOFA_m_x4, 
  view = "CyTOF_prcnt", 
  factors = 1:5,
  show_colnames = T, main = 'CyTOF_prcnt'
)

plotTopWeights(
  MOFA_m_x4, 
  view="CyTOF_prcnt", 
  factor=5
)

plotTopWeights(
  MOFA_m_x4, 
  view="CyTOF_prcnt", 
  factor=4
)

plotTopWeights(
  MOFA_m_x4, 
  view="CyTOF_prcnt", 
  factor=2
)

CyTOF expression

plotWeightsHeatmap(
  MOFA_m_x4, 
  view = "CyTOF_exp", 
  factors = 1:5,
  show_colnames = FALSE, main = 'CyTOF_exp'
)

plotTopWeights(
  MOFA_m_x4, 
  view="CyTOF_exp", 
  factor=3
)

plotTopWeights(
  MOFA_m_x4, 
  view="CyTOF_exp", 
  factor=5
)

plotTopWeights(
  MOFA_m_x4, 
  view="CyTOF_exp", 
  factor=1
)

plotTopWeights(
  MOFA_m_x4, 
  view="CyTOF_exp", 
  factor=2
)

RNA Seq Top genes

plotWeightsHeatmap(
  MOFA_m_x4, 
  view = "RNA_topgenes", 
  factors = 1:5,
  show_colnames = FALSE, main = 'RNA_topgenes'
)

plotTopWeights(
  MOFA_m_x4, 
  view="RNA_topgenes", 
  factor=1
)

plotTopWeights(
  MOFA_m_x4, 
  view="RNA_topgenes", 
  factor=1
)

plotTopWeights(
  MOFA_m_x4, 
  view="RNA_topgenes", 
  factor=1
)

plotTopWeights(
  MOFA_m_x4, 
  view="RNA_topgenes", 
  factor=1
)

RNA Seq Deconvolution

plotWeightsHeatmap(
  MOFA_m_x4, 
  view = "RNA_xcell", 
  factors = 1:5,
  show_colnames = T, main = 'RNA_xcell'
)

plotTopWeights(
  MOFA_m_x4, 
  view="RNA_xcell", 
  factor=2
)

plotTopWeights(
  MOFA_m_x4, 
  view="RNA_xcell", 
  factor=1
)

plotTopWeights(
  MOFA_m_x4, 
  view="RNA_xcell", 
  factor=4
)

plotTopWeights(
  MOFA_m_x4, 
  view="RNA_xcell", 
  factor=5
)

WES

plotWeightsHeatmap(
  MOFA_m_x4, 
  view = "mutation", 
  factors = 1:5,
  show_colnames = F, main = 'Mutation Data'
)

plotTopWeights(
  MOFA_m_x4, 
  view="mutation", 
  factor=1
)

plotTopWeights(
  MOFA_m_x4, 
  view="mutation", 
  factor=1
)

plotTopWeights(
  MOFA_m_x4, 
  view="mutation", 
  factor=1
)

plotTopWeights(
  MOFA_m_x4, 
  view="mutation", 
  factor=1
)

Feature set enrichment analysis in the active views

# Load reactome annotations
data("reactomeGS") # binary matrix with feature sets in rows and features in columns

# perform enrichment analysis
gsea <- runEnrichmentAnalysis(
  MOFA_m_x4,
  view = "RNA_topgenes",
  feature.sets = reactomeGS,
  alpha = 0.01
)
## Doing Feature Set Enrichment Analysis with the following options...
## View: RNA_topgenes
## Factors: LF1 LF2 LF3 LF4 LF5 LF6 LF7 LF8 LF9 LF10
## Number of feature sets: 640
## Local statistic: loading
## Transformation: abs.value
## Global statistic: mean.diff
## Statistical test: parametric
plotEnrichmentBars(gsea, alpha=0.01)

interestingFactors <- 1:2

fseaplots <- lapply(interestingFactors, function(factor) {
  plotEnrichment(
    MOFA_m_x4,
    gsea,
    factor = factor,
    alpha = 0.01,
    max.pathways = 10 # The top number of pathways to display
  )
})

cowplot::plot_grid(fseaplots[[1]], fseaplots[[2]],
                   ncol = 1, labels = paste("Factor", interestingFactors))

interestingFactors <- 3:4

fseaplots <- lapply(interestingFactors, function(factor) {
  plotEnrichment(
    MOFA_m_x4,
    gsea,
    factor = factor,
    alpha = 0.01,
    max.pathways = 10 # The top number of pathways to display
  )
})

cowplot::plot_grid(fseaplots[[1]], fseaplots[[2]],
                   ncol = 1, labels = paste("Factor", interestingFactors))

interestingFactors <- 5:6

fseaplots <- lapply(interestingFactors, function(factor) {
  plotEnrichment(
    MOFA_m_x4,
    gsea,
    factor = factor,
    alpha = 0.01,
    max.pathways = 10 # The top number of pathways to display
  )
})

cowplot::plot_grid(fseaplots[[1]], fseaplots[[2]],
                   ncol = 1, labels = paste("Factor", interestingFactors))

plotFactorScatter(
  MOFA_m_x4,
  factors = 1:2,
  color_by = "ImmuneScore"      # color by the IGHV values that are part of the training data
  #shape_by = "trisomy12"  # shape by the trisomy12 values that are part of the training data
)

plotFactorScatters(
  MOFA_m_x4,
  factors = c(1:5),
  color_by = "ImmuneScore"
)

plotFactorScatters(
  MOFA_m_x4,
  factors = c(1:5),
  color_by = "Th_cells"
)

plotFactorScatters(
  MOFA_m_x4,
  factors = c(1:5),
  color_by = "Tc_cells"
)

plotFactorScatters(
  MOFA_m_x4,
  factors = c(1:5),
  color_by = "KRAS"
)

plotFactorScatters(
  MOFA_m_x4,
  factors = c(1:5),
  color_by = "EGFR"
)

MOFA model + EpiDISH + VIPER 25

plotDataOverview(MOFA_m_e25)

Analyze trained MOFA model

# Calculate the variance explained (R2) per factor in each view 
r2 <- calculateVarianceExplained(MOFA_m_e25)
r2$R2Total
##    CyTOF_exp  CyTOF_prcnt  RNA_epidish RNA_topgenes  RNA_viper25     mutation 
##   0.11553712   0.06503805   0.37666450   0.43951638   0.68737716   0.06443597
# Variance explained by each factor in each view
head(r2$R2PerFactor)
##        CyTOF_exp CyTOF_prcnt  RNA_epidish RNA_topgenes RNA_viper25     mutation
## LF1 0.0001343032 0.005526604 2.236585e-01   0.05150576  0.08653719 4.485793e-05
## LF2 0.0101933986 0.013242724 2.312529e-02   0.10309008  0.13888167 6.393188e-02
## LF3 0.0001835709 0.001488031 6.053233e-02   0.08948466  0.16638152 4.904507e-05
## LF4 0.0885562816 0.026066946 6.011119e-05   0.04137867  0.02738389 4.820525e-05
## LF5 0.0006020680 0.004083677 2.151768e-03   0.02301456  0.10351271 7.980884e-05
## LF6 0.0164341056 0.012762354 2.790510e-02   0.01710937  0.05868396 2.697200e-05
# Plot it
plotVarianceExplained(MOFA_m_e25)

Characterization of individual factors

CyTOF percentages

plotWeightsHeatmap(
  MOFA_m_e25, 
  view = "CyTOF_prcnt", 
  factors = 1:5,
  show_colnames = T, main = 'CyTOF_prcnt'
)

plotTopWeights(
  MOFA_m_e25, 
  view="CyTOF_prcnt", 
  factor=5
)

plotTopWeights(
  MOFA_m_e25, 
  view="CyTOF_prcnt", 
  factor=4
)

plotTopWeights(
  MOFA_m_e25, 
  view="CyTOF_prcnt", 
  factor=2
)

CyTOF expression

plotWeightsHeatmap(
  MOFA_m_e25, 
  view = "CyTOF_exp", 
  factors = 1:5,
  show_colnames = FALSE, main = 'CyTOF_exp'
)

plotTopWeights(
  MOFA_m_e25, 
  view="CyTOF_exp", 
  factor=3
)

plotTopWeights(
  MOFA_m_e25, 
  view="CyTOF_exp", 
  factor=5
)

plotTopWeights(
  MOFA_m_e25, 
  view="CyTOF_exp", 
  factor=1
)

plotTopWeights(
  MOFA_m_e25, 
  view="CyTOF_exp", 
  factor=2
)

RNA Seq Top genes

plotWeightsHeatmap(
  MOFA_m_e25, 
  view = "RNA_topgenes", 
  factors = 1:5,
  show_colnames = FALSE, main = 'RNA_topgenes'
)

plotTopWeights(
  MOFA_m_e25, 
  view="RNA_topgenes", 
  factor=1
)

plotTopWeights(
  MOFA_m_e25, 
  view="RNA_topgenes", 
  factor=1
)

plotTopWeights(
  MOFA_m_e25, 
  view="RNA_topgenes", 
  factor=1
)

plotTopWeights(
  MOFA_m_e25, 
  view="RNA_topgenes", 
  factor=1
)

RNA Seq Deconvolution

plotWeightsHeatmap(
  MOFA_m_e25, 
  view = "RNA_epidish", 
  factors = 1:5,
  show_colnames = T, main = 'RNA_epidish'
)

plotTopWeights(
  MOFA_m_e25, 
  view="RNA_epidish", 
  factor=2
)

plotTopWeights(
  MOFA_m_e25, 
  view="RNA_epidish", 
  factor=1
)

plotTopWeights(
  MOFA_m_e25, 
  view="RNA_epidish", 
  factor=4
)

plotTopWeights(
  MOFA_m_e25, 
  view="RNA_epidish", 
  factor=5
)

WES

plotWeightsHeatmap(
  MOFA_m_e25, 
  view = "mutation", 
  factors = 1:5,
  show_colnames = F, main = 'Mutation Data'
)

plotTopWeights(
  MOFA_m_e25, 
  view="mutation", 
  factor=1
)

plotTopWeights(
  MOFA_m_e25, 
  view="mutation", 
  factor=1
)

plotTopWeights(
  MOFA_m_e25, 
  view="mutation", 
  factor=1
)

plotTopWeights(
  MOFA_m_e25, 
  view="mutation", 
  factor=1
)

Feature set enrichment analysis in the active views

# Load reactome annotations
data("reactomeGS") # binary matrix with feature sets in rows and features in columns

# perform enrichment analysis
gsea <- runEnrichmentAnalysis(
  MOFA_m_e25,
  view = "RNA_topgenes",
  feature.sets = reactomeGS,
  alpha = 0.01
)
## Doing Feature Set Enrichment Analysis with the following options...
## View: RNA_topgenes
## Factors: LF1 LF2 LF3 LF4 LF5 LF6 LF7 LF8 LF9 LF10
## Number of feature sets: 640
## Local statistic: loading
## Transformation: abs.value
## Global statistic: mean.diff
## Statistical test: parametric
plotEnrichmentBars(gsea, alpha=0.01)

interestingFactors <- 1:2

fseaplots <- lapply(interestingFactors, function(factor) {
  plotEnrichment(
    MOFA_m_e25,
    gsea,
    factor = factor,
    alpha = 0.01,
    max.pathways = 10 # The top number of pathways to display
  )
})

cowplot::plot_grid(fseaplots[[1]], fseaplots[[2]],
                   ncol = 1, labels = paste("Factor", interestingFactors))

interestingFactors <- 3:4

fseaplots <- lapply(interestingFactors, function(factor) {
  plotEnrichment(
    MOFA_m_e25,
    gsea,
    factor = factor,
    alpha = 0.01,
    max.pathways = 10 # The top number of pathways to display
  )
})

cowplot::plot_grid(fseaplots[[1]], fseaplots[[2]],
                   ncol = 1, labels = paste("Factor", interestingFactors))

interestingFactors <- 5:6

fseaplots <- lapply(interestingFactors, function(factor) {
  plotEnrichment(
    MOFA_m_e25,
    gsea,
    factor = factor,
    alpha = 0.01,
    max.pathways = 10 # The top number of pathways to display
  )
})

cowplot::plot_grid(fseaplots[[1]], fseaplots[[2]],
                   ncol = 1, labels = paste("Factor", interestingFactors))

plotFactorScatters(
  MOFA_m_e25,
  factors = c(1:5),
  color_by = "Th_cells"
)

plotFactorScatters(
  MOFA_m_e25,
  factors = c(1:5),
  color_by = "Tc_cells"
)

plotFactorScatters(
  MOFA_m_e25,
  factors = c(1:5),
  color_by = "KRAS"
)

plotFactorScatters(
  MOFA_m_e25,
  factors = c(1:5),
  color_by = "EGFR"
)

MOFA model + EpiDISH + VIPER 4

plotDataOverview(MOFA_m_e4)

Analyze trained MOFA model

# Calculate the variance explained (R2) per factor in each view 
r2 <- calculateVarianceExplained(MOFA_m_e4)
r2$R2Total
##    CyTOF_exp  CyTOF_prcnt  RNA_epidish RNA_topgenes   RNA_viper4     mutation 
##   0.11599445   0.06493035   0.37737421   0.43952482   0.57569168   0.06514388
# Variance explained by each factor in each view
head(r2$R2PerFactor)
##        CyTOF_exp CyTOF_prcnt  RNA_epidish RNA_topgenes RNA_viper4     mutation
## LF1 0.0001425716 0.005552850 2.250425e-01   0.05144924 0.07776017 4.480380e-05
## LF2 0.0102215277 0.013063389 2.107351e-02   0.10334330 0.11982511 6.464697e-02
## LF3 0.0001799317 0.001556641 6.213197e-02   0.08928844 0.13553456 4.701630e-05
## LF4 0.0891707850 0.026472316 6.144777e-05   0.04133211 0.01970607 4.651060e-05
## LF5 0.0162206720 0.012200086 2.779923e-02   0.01708670 0.03946763 2.648969e-05
## LF6 0.0006057104 0.004164464 2.448574e-03   0.02308369 0.07156277 8.073406e-05
# Plot it
plotVarianceExplained(MOFA_m_e4)

Characterization of individual factors

CyTOF percentages

plotWeightsHeatmap(
  MOFA_m_e4, 
  view = "CyTOF_prcnt", 
  factors = 1:5,
  show_colnames = T, main = 'CyTOF_prcnt'
)

plotTopWeights(
  MOFA_m_e4, 
  view="CyTOF_prcnt", 
  factor=5
)

plotTopWeights(
  MOFA_m_e4, 
  view="CyTOF_prcnt", 
  factor=4
)

plotTopWeights(
  MOFA_m_e4, 
  view="CyTOF_prcnt", 
  factor=2
)

CyTOF expression

plotWeightsHeatmap(
  MOFA_m_e4, 
  view = "CyTOF_exp", 
  factors = 1:5,
  show_colnames = FALSE, main = 'CyTOF_exp'
)

plotTopWeights(
  MOFA_m_e4, 
  view="CyTOF_exp", 
  factor=3
)

plotTopWeights(
  MOFA_m_e4, 
  view="CyTOF_exp", 
  factor=5
)

plotTopWeights(
  MOFA_m_e4, 
  view="CyTOF_exp", 
  factor=1
)

plotTopWeights(
  MOFA_m_e4, 
  view="CyTOF_exp", 
  factor=2
)

RNA Seq Top genes

plotWeightsHeatmap(
  MOFA_m_e4, 
  view = "RNA_topgenes", 
  factors = 1:5,
  show_colnames = FALSE, main = 'RNA_topgenes'
)

plotTopWeights(
  MOFA_m_e4, 
  view="RNA_topgenes", 
  factor=1
)

plotTopWeights(
  MOFA_m_e4, 
  view="RNA_topgenes", 
  factor=1
)

plotTopWeights(
  MOFA_m_e4, 
  view="RNA_topgenes", 
  factor=1
)

plotTopWeights(
  MOFA_m_e4, 
  view="RNA_topgenes", 
  factor=1
)

RNA Seq Deconvolution

plotWeightsHeatmap(
  MOFA_m_e4, 
  view = "RNA_epidish", 
  factors = 1:5,
  show_colnames = T, main = 'RNA_epidish'
)

plotTopWeights(
  MOFA_m_e4, 
  view="RNA_epidish", 
  factor=2
)

plotTopWeights(
  MOFA_m_e4, 
  view="RNA_epidish", 
  factor=1
)

plotTopWeights(
  MOFA_m_e4, 
  view="RNA_epidish", 
  factor=4
)

plotTopWeights(
  MOFA_m_e4, 
  view="RNA_epidish", 
  factor=5
)

WES

plotWeightsHeatmap(
  MOFA_m_e4, 
  view = "mutation", 
  factors = 1:5,
  show_colnames = F, main = 'Mutation Data'
)

plotTopWeights(
  MOFA_m_e4, 
  view="mutation", 
  factor=1
)

plotTopWeights(
  MOFA_m_e4, 
  view="mutation", 
  factor=1
)

plotTopWeights(
  MOFA_m_e4, 
  view="mutation", 
  factor=1
)

plotTopWeights(
  MOFA_m_e4, 
  view="mutation", 
  factor=1
)

Feature set enrichment analysis in the active views

# Load reactome annotations
data("reactomeGS") # binary matrix with feature sets in rows and features in columns

# perform enrichment analysis
gsea <- runEnrichmentAnalysis(
  MOFA_m_e4,
  view = "RNA_topgenes",
  feature.sets = reactomeGS,
  alpha = 0.01
)
## Doing Feature Set Enrichment Analysis with the following options...
## View: RNA_topgenes
## Factors: LF1 LF2 LF3 LF4 LF5 LF6 LF7 LF8 LF9 LF10
## Number of feature sets: 640
## Local statistic: loading
## Transformation: abs.value
## Global statistic: mean.diff
## Statistical test: parametric
plotEnrichmentBars(gsea, alpha=0.01)

interestingFactors <- 1:2

fseaplots <- lapply(interestingFactors, function(factor) {
  plotEnrichment(
    MOFA_m_e4,
    gsea,
    factor = factor,
    alpha = 0.01,
    max.pathways = 10 # The top number of pathways to display
  )
})

cowplot::plot_grid(fseaplots[[1]], fseaplots[[2]],
                   ncol = 1, labels = paste("Factor", interestingFactors))

interestingFactors <- 3:4

fseaplots <- lapply(interestingFactors, function(factor) {
  plotEnrichment(
    MOFA_m_e4,
    gsea,
    factor = factor,
    alpha = 0.01,
    max.pathways = 10 # The top number of pathways to display
  )
})

cowplot::plot_grid(fseaplots[[1]], fseaplots[[2]],
                   ncol = 1, labels = paste("Factor", interestingFactors))

interestingFactors <- 5:6

fseaplots <- lapply(interestingFactors, function(factor) {
  plotEnrichment(
    MOFA_m_e4,
    gsea,
    factor = factor,
    alpha = 0.01,
    max.pathways = 10 # The top number of pathways to display
  )
})

cowplot::plot_grid(fseaplots[[1]], fseaplots[[2]],
                   ncol = 1, labels = paste("Factor", interestingFactors))

plotFactorScatters(
  MOFA_m_e4,
  factors = c(1:5),
  color_by = "Th_cells"
)

plotFactorScatters(
  MOFA_m_e4,
  factors = c(1:5),
  color_by = "Tc_cells"
)

plotFactorScatters(
  MOFA_m_e4,
  factors = c(1:5),
  color_by = "KRAS"
)

plotFactorScatters(
  MOFA_m_e4,
  factors = c(1:5),
  color_by = "EGFR"
)